import { createStore } from 'vuex';
import createPersistedState from "vuex-persistedstate";

const store = createStore({
  state: {
    userInfo: null,
    token: null
  },
  mutations: {
    userInfoChange(state, payload) {
      state.userInfo = payload
    },
    tokenChange(state, payload) {
      state.token = payload
    }
  },
  actions: {
    userInfoAyncChange(context) {
      context.commit('userInfoChange', {})
    },
    tokenAyncChange(context) {
      context.commit('tokenChange', {})
    }
  },
  plugins: [createPersistedState()]
});

export default store;